package com.daotingli.backendprograms;

import com.daotingli.backendprograms.AppCongfig.AppCongfig;
import com.daotingli.backendprograms.Controller.Admin.Adminherd.AdminHerdController;
import com.daotingli.backendprograms.Controller.Admin.Authoer.AuthoerController;
import com.daotingli.backendprograms.Controller.Admin.AuthorBook.AuthorBookController;
import com.daotingli.backendprograms.Controller.Admin.Reader.ReaderController;
import com.daotingli.backendprograms.Controller.Admin.Tag.TagController;
import com.daotingli.backendprograms.Controller.Author.booktype.BookTypeController;
import com.daotingli.backendprograms.Controller.Author.individual.IndividualController;
import com.daotingli.backendprograms.Repository.Admin.Adminherd.AdminHerdRepository;
import com.daotingli.backendprograms.Repository.Admin.Authoer.AuthoerRepository;
import com.daotingli.backendprograms.Repository.Admin.AuthorBook.AuthorBookRepository;
import com.daotingli.backendprograms.Repository.Admin.Reader.ReaderRepository;
import com.daotingli.backendprograms.Repository.Admin.Tag.TagRepository;

import com.daotingli.backendprograms.Repository.Author.booktype.BookTypeRepository;
import com.daotingli.backendprograms.Repository.Author.individual.IndividualRepository;
import com.daotingli.backendprograms.utils.CreateBookName;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;



@SpringBootApplication

public class BackEndProgramsApplication {
    @Autowired
    private AppCongfig appCongfig;
    @Autowired
    private TagController  tagController;
    @Autowired
    private TagRepository tagRepository;
    @Autowired
    private ReaderController  readerController;
    @Autowired
    private ReaderRepository  readerRepository;
    @Autowired
    private AuthoerController authoerController;
    @Autowired
    private AuthoerRepository authoerRepository;
    @Autowired
    private AuthorBookController authorBookController;
    @Autowired
    private AuthorBookRepository authorBookRepository;

    @Autowired
    private AdminHerdRepository adminHerdRepository;
    @Autowired
    private AdminHerdController adminHerdController;
    @Autowired
    private IndividualRepository  individualRepository;
    @Autowired
    private IndividualController individualController;
    @Autowired
    private BookTypeController  bookTypeController;
    @Autowired
    private BookTypeRepository bookTypeRepository;
    @Autowired
    private CreateBookName createBookName;

    public static void main(String[] args) {
        System.out.println("开始启动...");
        ConfigurableApplicationContext  context = SpringApplication.run(BackEndProgramsApplication.class, args);
        System.out.println("启动进行...");
        BackEndProgramsApplication app=  context.getBean(BackEndProgramsApplication.class);
        System.out.println("启动成功...");
        System.out.println("\n\n");
        System.out.println("appName:"+ app.appCongfig.getAppName());
        System.out.println("appPort:"+ app.appCongfig.getPort());
        System.out.println("\n\n");
        System.out.println("SqlURl:"+  app.appCongfig.getDbUrl());
        System.out.println("SqlUserName:"+  app.appCongfig.getDbUserName());
        System.out.println("SqlPassword:"+  app.appCongfig.getDbPassword());
        System.out.println("SqlDriver:"+  app.appCongfig.getDbDriverClassName());
        System.out.println("SqlType:"+  app.appCongfig.getDbType());
        System.out.println("appUrl:http://localhost:"+ app.appCongfig.getPort());
        System.out.println("\n\n");
        System.out.println("tagAll:"+  app.tagController.getAllTags());
        System.out.println("tag:"+  app.tagRepository.getAllTag());
        System.out.println("\n\n");
        System.out.println("readerAll:"+  app.readerController.getAllReaders());
        System.out.println("reader:"+  app.readerRepository.getAllReaders());
        System.out.println("\n\n");
        System.out.println("authoerAll:"+  app.authoerController.getAllAuthoers());
        System.out.println("authoer:"+  app.authoerRepository.getAllAuthoers());
        System.out.println("\n\n");
        System.out.println("authorBookAll:"+  app.authorBookController.getAllAuthorBooks());
        System.out.println("authorBook:"+  app.authorBookRepository.getAllAuthorBooks());
        System.out.println("\n\n");
        System.out.println("Book_author:"+  app.authorBookRepository.getAllAuthors());
        System.out.println("\n\n");
        System.out.println("adminAll:"+  app.adminHerdController.getAllHerds());
        System.out.println("admin:"+  app.adminHerdRepository.getAllHerds());
        System.out.println("\n\n");
        System.out.println("Book_author_sum:"+  app.adminHerdController.getBookAuthorSum());
        System.out.println("Book_author_sum:"+  app.adminHerdRepository.getBookAuthorSum());
        System.out.println("\n\n");
        System.out.println("Book_type_sum:"+  app.adminHerdController.getBookTypeSum());
        System.out.println("Book_type_sum:"+  app.adminHerdRepository.getBookTypeSum());
        System.out.println("\n\n");
        System.out.println("Book_tag_sum:"+  app.adminHerdController.getBookTagSum());
        System.out.println("Book_tag_sum:"+  app.adminHerdRepository.getBookTagSum());
        System.out.println("\n\n");
        System.out.println("individualAll:"+  app.individualController.getAll("writer","123"));
        System.out.println("individual:"+  app.individualRepository.getAll("writer","123"));
        System.out.println("\n\n");
        System.out.println("book作者_id:"+  app.bookTypeController.getAll("writer","123"));
        System.out.println("book作者_id:"+  app.bookTypeRepository.getAll("writer","123"));
        System.out.println("\n\n");
        System.out.println("bookTypeAll_book:"+  app.bookTypeController.getAllBooks(3));
        System.out.println("bookType_book:"+  app.bookTypeRepository.getAllBooks(3));
        System.out.println("\n\n");
        System.out.println("bookTypeAll_book_id:"+  app.bookTypeController.getAuthorBookIDs(3));
        System.out.println("bookType_book_id:"+  app.bookTypeRepository.getAuthorBookIDs(3));
        System.out.println("\n\n");
        System.out.println("bookTypeAll_book_tag:"+  app.bookTypeController.getBookTag(2));
        System.out.println("bookType_book_tag:"+  app.bookTypeRepository.getBookTag(2));
        System.out.println("\n\n");
        System.out.println("bookTypeAll_book_tag:"+  app.bookTypeController.getAuthorInfo(3));
        System.out.println("bookType_book_tag:"+  app.bookTypeRepository.getAuthorInfo(3));

        for (int i=0;i<20;i++){
            System.out.println("CreatBookName:"+ app.createBookName.generateRandomBookName());
        }

    }

}
